package org.taohuawu.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.taohuawu.pojo.User;
import org.taohuawu.service.fallback.UserFeignServiceFallback;
import org.taohuawu.web.util.JsonResult;

@FeignClient(name = "user-service", fallback = UserFeignServiceFallback.class)
@RequestMapping("/user")
public interface UserFeignService {
    @GetMapping("/{userId}")
    public JsonResult<User> getUser(@PathVariable Integer userId);

    /**
     * 如果方法参数 score 不加 @RequestParam 注解，会报一下错误：
     * feign.FeignException$MethodNotAllowed: status 405 reading UserFeignService#addScore(Integer,Integer)
     * @param userId
     * @param score
     * @return
     */
    @GetMapping("/{userId}/score")
    public JsonResult addScore(@PathVariable Integer userId, @RequestParam Integer score);
}
